package org.zzk.handler;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

public class ChessServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) {
        ChannelPipeline pipeline = ch.pipeline();

        // 协议处理链
        pipeline.addLast(new SplitHandler());  // 剥离字节数
        pipeline.addLast(ChessPacketCodecHandler.INSTANCE);
        pipeline.addLast(MatchRequestHandler.INSTANCE);
        pipeline.addLast(ChessMoveHandler.INSTANCE);

        // 空闲检测
        //pipeline.addLast(new IdleStateHandler(30, 0, 0));
        //pipeline.addLast(new HeartbeatHandler());

        // 异常处理
        pipeline.addLast(TailExceptionHandler.INSTANCE);
    }
}
